package iface;

public class PrintMessage implements IPrintMessage {

    int i = 0;
    String[] message;

    public PrintMessage() {
        message = new String[3];
        putMessage("Hello World!");
        putMessage("Hello China!");
        putMessage("Hello JiangYou!");
    }

    void putMessage(String str) {
        message[i++] = str;
    }

    @Override
    public void printAllMessage() {
        for (int j = 0; j < message.length; j++) {
            System.out.println(message[j]);
        }
    }

    @Override
    public void printLastMessage() {
        System.out.println(message[message.length - 1]);
    }

    @Override
    public void printFirstMessage() {
        System.out.println(message[0]);
    }
}